package com.yzt.exce;

import javax.servlet.http.HttpServletRequest;

import org.apache.shiro.authz.AuthorizationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalException {

	private static final Logger logger = LoggerFactory.getLogger(GlobalException.class);

	@ExceptionHandler(value = AuthorizationException.class)
	Object authorizationException(Exception e, HttpServletRequest request) {
		logger.error(e.getMessage(), e);
		return "用户未登录或登录已超时";
	}

	@ExceptionHandler(value = Exception.class)
	Object exception(Exception e, HttpServletRequest request) {
		logger.error(e.getMessage(), e);
		return "系统异常，请稍候重试";
	}

}
